﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Baopx_API;

namespace Baopx.BackEnd.Control
{
    public partial class UsrHeader : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Account account = A.M.GetAccountFromCookies();
                if (account != null)
                {
                    litUserName.Text = account.UserName;
                    A.M.SetCookie("BackEndCurrentPage",A.M.GetUrlCurrent());
                }
                else
                    A.M.Redirect("/BackEnd/MangeAccount/Login.aspx");
            }
        }

        protected void btnLogout_Click(object sender, EventArgs e)
        {
            A.M.DeleteAccountLoginInCookies();
            A.M.RefreshCurrentPage();
        }
    }
}